package extracter;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;

import producer.UploadToMQ;

public class ExtractFromFile {
	
	/**
	 * read the msg from outside file, and then send to MQ
	 * @throws IOException
	 * @throws JMSException
	 */
	public void extract() throws IOException, JMSException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("Books.json")));
		
		for(int i=0; i<10; i++){
			String[] strings = new String[1000];
			for(int j=0; j<1000; j++){
				strings[j] = reader.readLine();
			}
			UploadToMQ.upload(strings);
		}
		
		reader.close();
	}

	public static void main(String[] args) throws IOException, JMSException {
		new ExtractFromFile().extract();
	}
}
